package cn.zhaoyuening.schoolmates.web.general;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cn.zhaoyuening.schoolmates.domain.PhotosCategory;
import cn.zhaoyuening.schoolmates.domain.SchoolmatesCategory;
import cn.zhaoyuening.schoolmates.service.PhotosCategoryService;
import cn.zhaoyuening.schoolmates.service.SchoolmatesCategoryService;
import cn.zhaoyuening.schoolmates.utils.JsonUtils;
import cn.zhaoyuening.schoolmates.utils.page.PageBean;

@RestController
public class PhotosCategoryController {
	@Autowired
	private PhotosCategoryService photosCategoryService;

	@RequestMapping(value="photosCategorys",method=RequestMethod.GET)
	public String articleCategory(String order, Integer offset, Integer limit) {
		Long total = photosCategoryService.getTotalRecord();
		List<PhotosCategory> list = photosCategoryService.findAll(null, null, offset, limit,"id "+order);
		PageBean<PhotosCategory> pageBean = new PageBean<>(total, list);
		return JsonUtils.objectToJson(pageBean);
	}
	
	@RequestMapping(value="allPhotosCategorys",method=RequestMethod.GET,produces="application/json;charset=utf-8")
	public String findAll() {
		List<PhotosCategory> list = photosCategoryService.findAll();
		return JsonUtils.objectToJson(list);
	}


}
